﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MonoGame.Framework;
using Microsoft.Xna.Framework;

namespace TunnelsOfDeath.Objects
{
    /// <summary>
    /// Contains default objects to populate gamemap.
    /// </summary>
    class Generator
    {

        public Sprite GetDirt(Vector2 _position)
        {
            Dictionary<Direction, int> animationFrames = new Dictionary<Direction, int>();
            Dictionary<Direction, Vector2> animationTable = new Dictionary<Direction, Vector2>();
            animationFrames.Add(Direction.stopped, 1);
            animationTable.Add(Direction.stopped, new Vector2(0, 0));
            Sprite toReturn = new Sprite(0, animationTable, animationFrames, ObjectType.dirt, _position, 0);
            return toReturn;
        }

        public FallingDown GetRock(Vector2 _position)
        {
            Dictionary<Direction, int> animationFrames = new Dictionary<Direction, int>();
            Dictionary<Direction, Vector2> animationTable = new Dictionary<Direction, Vector2>();
            animationFrames.Add(Direction.stopped, 1);
            animationFrames.Add(Direction.down, 1);
            animationTable.Add(Direction.stopped, new Vector2(0, 0));
            animationTable.Add(Direction.down, new Vector2(0, 0));
            FallingDown toReturn = new FallingDown(1, animationTable, animationFrames, ObjectType.rock, _position, 0);
            return toReturn;
        }

        public Sprite GetWall(Vector2 _position)
        {
            Dictionary<Direction, int> animationFrames = new Dictionary<Direction, int>();
            Dictionary<Direction, Vector2> animationTable = new Dictionary<Direction, Vector2>();
            animationFrames.Add(Direction.stopped, 1);
            animationTable.Add(Direction.stopped, new Vector2(0, 0));
            Sprite toReturn = new Sprite(2, animationTable, animationFrames, ObjectType.wall, _position, 0);
            return toReturn;
        }

        public FallingDown GetGold(Vector2 _position)
        {
            Dictionary<Direction, int> animationFrames = new Dictionary<Direction, int>();
            Dictionary<Direction, Vector2> animationTable = new Dictionary<Direction, Vector2>();
            animationFrames.Add(Direction.stopped, 1);
            animationFrames.Add(Direction.down, 1);
            animationTable.Add(Direction.stopped, new Vector2(0, 0));
            animationTable.Add(Direction.down, new Vector2(0, 0));
            FallingDown toReturn = new FallingDown(3, animationTable, animationFrames, ObjectType.crystal, _position, 0);
            return toReturn;
        }

        public Player GetPlayer(Vector2 _position, ControllerSource _controller, int _model)
        {
            Dictionary<Direction, int> animationFrames = new Dictionary<Direction, int>();
            Dictionary<Direction, Vector2> animationTable = new Dictionary<Direction, Vector2>();
            animationFrames.Add(Direction.stopped, 1);
            animationFrames.Add(Direction.down, 1);
            animationTable.Add(Direction.stopped, new Vector2(0, 0));
            animationTable.Add(Direction.down, new Vector2(0, 0));
            Player toReturn = new Player(4+(_model-1), animationTable, animationFrames, ObjectType.player, _position, 0,_controller);
            return toReturn;
        }

        public Explosion GetExplosion(Vector2 _position)
        {
            Dictionary<Direction, int> animationFrames = new Dictionary<Direction, int>();
            Dictionary<Direction, Vector2> animationTable = new Dictionary<Direction, Vector2>();
            animationFrames.Add(Direction.stopped, 25);
            animationTable.Add(Direction.stopped, new Vector2(0, 3));
            Explosion toReturn = new Explosion(6, animationTable, animationFrames, ObjectType.explosion, _position, 300);
            return toReturn;
        }

        public Enemy GetEnemy(Vector2 _position, bool _turnRight, short _delay)
        {
            Dictionary<Direction, int> animationFrames = new Dictionary<Direction, int>();
            Dictionary<Direction, Vector2> animationTable = new Dictionary<Direction, Vector2>();
            animationFrames.Add(Direction.stopped, 3);
            animationFrames.Add(Direction.down, 3);
            animationFrames.Add(Direction.up, 3);
            animationFrames.Add(Direction.left, 3);
            animationFrames.Add(Direction.right, 3);

            animationTable.Add(Direction.left, new Vector2(0, 0));
            animationTable.Add(Direction.right, new Vector2(0, 0));
            animationTable.Add(Direction.up, new Vector2(0, 0));
            animationTable.Add(Direction.down, new Vector2(0, 0));
            animationTable.Add(Direction.stopped, new Vector2(0, 0));
            Enemy toReturn = new Enemy(7, animationTable, animationFrames, ObjectType.enemy, _position, 300,_turnRight,_delay);
            return toReturn;
        }

        public Door GetDoor(Vector2 _position, int _requiredGold)
        {
            Dictionary<Direction, int> animationFrames = new Dictionary<Direction, int>();
            Dictionary<Direction, Vector2> animationTable = new Dictionary<Direction, Vector2>();
            animationFrames.Add(Direction.stopped, 1);
            animationTable.Add(Direction.stopped, new Vector2(0, 0));
            Door toReturn = new Door(8, animationTable, animationFrames, ObjectType.door, _position, 0, _requiredGold);
            return toReturn;
        }

    }
}
